﻿@model IEnumerable<HotelManageSystem.Models.BiographyOutline>
<link href= "@Url.Content("~/Content/TelerikGrid.css")"rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //员工离职
        $(".DimissionButton").click(function () {
            var dimissionId = $(this).attr("dimissionId");
            $.get("/Dimission/Dimission/" + dimissionId, null, function (data) {
                $("#content").html(data);
            });
            //设置当前位置为/Biography/Dimission,防止刷新跳转到/Biography/Index
            $.post("HumanResources/SetSeesion", { u: "/Biography/Dimission/" + dimissionId }, function () { });
        });
    });

    function onDataBound() {
        //员工离职
        $(".DimissionButton").click(function () {
            var dimissionId = $(this).attr("dimissionId");
            $.get("/Biography/Dimission/" + dimissionId, null, function (data) {
                $("#content").html(data);
            });
            //设置当前位置为/Biography/Dimission,防止刷新跳转到/Biography/Index
            $.post("HumanResources/SetSeesion", { u: "/Biography/Dimission/" + dimissionId }, function () { });
        });
    }
</script>
@(
 Html.Telerik().Grid(Model)
        .Name("BioGraphyOutlineGrid")
        .DataKeys(keys => keys.Add(b => b.ID))
        .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("TelerikAjax", "Biography")
        )
        .Sortable(sorting => sorting
            .SortMode(GridSortMode.SingleColumn))
        .Pageable(paging => paging
            .Style(GridPagerStyles.NextPreviousAndNumeric)
            .Position(GridPagerPosition.Bottom)
            .PageSize(12))
        .Columns(columns =>
                     {
                         columns.Bound(b => b.ID);
                         columns.Bound(b => b.Name);
                         columns.Bound(b => b.Sex);
                         columns.Bound(b => b.Department);
                         columns.Bound(b => b.Post);
                         columns.Bound(b => b.Degree);
                         columns.Bound(b => b.EmployeeStatus);
                         columns.Template(b => @Html.Raw("<input class='DimissionButton' type='button' value='离职' dimissionId='"
                                                         + b.ID + "'/>"))
                                         .ClientTemplate("<input class='DimissionButton' type='button' value='离职'" +
                                                         " dimissionId='<#= ID #>'/>");
                     })
        .Selectable()
        .Filterable()
        .ClientEvents(events => events//防止排序、过滤操作之后按钮无法调用脚本
                         .OnDataBound("onDataBound")
                     )
)